var t = getApp();

Page({
    data: {
        currentTab: 0,
        autoplay: !0,
        interval: 1500,
        duration: 500,
        vertical: !0,
        baseUrl: t.globalData.baseUrl,
        urlBase: t.globalData.urlBase
    },
    onLoad: function(a) {
        var e = this;
        wx.getStorageSync("userId") || t.goLogin(), e.setData({
            activityId: a.id,
            type: a.type,
            orderId: a.orderid ? a.orderid : ""
        }), this.getinitData();
    },
    getinitData: function() {
        var a = this, e = t.globalData.urlBase + t.globalData.urlactivitydetailList;
        wx.request({
            url: e,
            data: {
                activityId: a.data.activityId,
                type: a.data.type,
                lng: t.globalData.lng,
                lat: t.globalData.lat
            },
            method: "POST",
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                var e = JSON.parse(t.data);
                0 != e.code ? wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 2e3
                }) : (a.setData({
                    store: e.store,
                    serverList: e.serverList,
                    activity: e.activity,
                    imgUrls: e.activity.imgs.split(","),
                    type: a.data.type,
                    lat: e.store.lat,
                    lng: e.store.lng,
                    name: e.store.name,
                    address: e.store.address,
                    shareName: e.activity.name ? e.activity.name : "",
                    shareImg: e.activity.imgs.split(",")[0] ? e.activity.imgs.split(",")[0] : ""
                }), console.log(e));
            },
            fail: function(t) {
                console.log(".....fail.....");
            }
        });
    },
    openMap: function() {
        var t = this;
        wx.openLocation({
            latitude: parseFloat(t.data.lat),
            longitude: parseFloat(t.data.lng),
            name: t.data.name,
            address: t.data.address
        });
    },
    bindChange: function(t) {
        this.setData({
            currentTab: t.detail.current
        });
    },
    swichNav: function(t) {
        var a = this;
        if (this.data.currentTab === t.target.dataset.current) return !1;
        a.setData({
            currentTab: t.target.dataset.current
        });
    },
    groupaction: function(t) {
        var a = this;
        wx.navigateTo({
            url: "../activity/detail?id=" + t.currentTarget.dataset.id + "&type=" + t.currentTarget.dataset.type + "&orderid=" + a.data.orderId
        });
    },
    serverDetail: function(t) {
        wx.navigateTo({
            url: "../index/detail?id=" + t.currentTarget.dataset.id + "&type=" + t.currentTarget.dataset.type
        });
    },
    onShareAppMessage: function(t) {
        var a = this;
        return "button" === t.from ? (console.log("来自页面内转发按钮"), console.log(t.target)) : console.log("来自右上角转发菜单"), 
        {
            title: a.data.shareName,
            imageUrl: a.data.baseUrl + "download?id=" + a.data.shareImg,
            success: function(t) {
                console.log("转发成功", t);
            },
            fail: function(t) {
                console.log("转发失败", t);
            }
        };
    }
});